#include <stdio.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>

bool pollRead(int fd)
{
    fd_set set;
    struct timeval tv;
   
    tv.tv_sec = 0;
    tv.tv_usec = 0;
     
    FD_ZERO(&set);
    FD_SET(fd, &set);     

    select(fd + 1, &set, NULL, NULL, &tv);
    
    return FD_ISSET(fd, &set);
}

bool pollWrite(int fd)
{
    fd_set set;
    struct timeval tv;
   
    tv.tv_sec = 0;
    tv.tv_usec = 0;
     
    FD_ZERO(&set);
    FD_SET(fd, &set);     

    select(fd + 1, NULL, &set, NULL, &tv);
    
    return FD_ISSET(fd, &set);
}

bool pollErr(int fd)
{
    fd_set set;
    struct timeval tv;
   
    tv.tv_sec = 0;
    tv.tv_usec = 0;
     
    FD_ZERO(&set);
    FD_SET(fd, &set);     

    select(fd + 1, NULL, NULL, &set, &tv);
    
    return FD_ISSET(fd, &set);
}
